/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-29 20:00:45
 * @LastEditTime: 2021-08-29 20:03:42
 * @LastEditors: changqing
 * @Usage: 
 */

// 可以接受的参数类型包含Array,Promise,Iterable,Observable对象,与上面的of非常的像
var {from  } = require('rxjs');

from([1, 2, 3, 4]).subscribe(data => {
  console.log(`from 示例 (1): ${data}`);
});

// 使用generator
function* range(start, end) {
  for (let i = start; i <= end; ++i) {
  	yield i;
  }
}

from(range(1, 4)).subscribe((data) => {
	console.log(`from 示例 (2): ${data}`);
});

from(Promise.resolve(1)).subscribe(data => {
  console.log(`from 示例 (3): ${data}`);
});

// 会重新组成一个新的Observable
from(of(1, 2, 3, 4)).subscribe(data => {
  console.log(`from 示例 (4): ${data}`)
});